﻿Facoltà di Scienze Statistiche 

PROVA SCRITTA DI RETI DI CALCOLATORI
 
2 Settembre 2010 

Prof. M. Maresca, N. Zingirian 


Si modifichi il programma che implementa le funzioni base del nodo IP, in modo che sia in grado di riconoscere, in ricezione, oltre che il consueto messaggio ICMP “echo reply”, anche un altro tipo di messaggio ICMP,  chiamato “unreachable destination” di cui si riporta la documentazione dalla RFC 792. 

Si tenga presente che il messaggio “unreachable destination” viene generato da un router della rete, nel caso in cui rileva che il datagram IP che sta inoltrando è destinato ad un indirizzo che non potrà mai essere raggiunto. In tal caso il router: 
    1) elimina quel pacchetto IP (ossia non lo inoltra ad alcun altro router). 
    2) crea il  messaggio ICMP “unreachable destination” 
    3) spedisce il messaggio ICMP al nodo che ha generato il pacchetto IP privo di destinazione raggiungibile per avvertirlo che ha eliminato il pacchetto. 

Per effettuare il test del programma, si invii un’ “echo request” ad un indirizzo inesistente (es. indirizzo 10.20.30.40) per ottenere in risposta un messaggio di “Destination Unreachable” e si scriva su schermo l’indirizzo IP del nodo della rete che ha generato quel messaggio.

________________

Dalla RFC 792:

Destination Unreachable Message

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     Type      |     Code      |          Checksum             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                             unused                            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |      Internet Header + 64 bits of Original Data Datagram      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

   IP Fields:

   Destination Address

      The source network and address from the original datagram's data.

   ICMP Fields:

   Type

      3

   Code

      0 = net unreachable;

      1 = host unreachable;

      2 = protocol unreachable;

      3 = port unreachable;

      4 = fragmentation needed and DF set;

      5 = source route failed.

   Checksum

      The checksum is the 16-bit ones's complement of the one's
      complement sum of the ICMP message starting with the ICMP Type.
      For computing the checksum , the checksum field should be zero.
      This checksum may be replaced in the future.

   Internet Header + 64 bits of Data Datagram

      The internet header plus the first 64 bits of the original
      datagram's data.  This data is used by the host to match the
      message to the appropriate process.  If a higher level protocol
      uses port numbers, they are assumed to be in the first 64 data
      bits of the original datagram's data.

   Description

      If, according to the information in the gateway's routing tables,
      the network specified in the internet destination field of a
      datagram is unreachable, e.g., the distance to the network is
      infinity, the gateway may send a destination unreachable message
      to the internet source host of the datagram.  In addition, in some
      networks, the gateway may be able to determine if the internet
      destination host is unreachable.  Gateways in these networks may
      send destination unreachable messages to the source host when the
      destination host is unreachable.

      If, in the destination host, the IP module cannot deliver the
      datagram  because the indicated protocol module or process port is
      not active, the destination host may send a destination
      unreachable message to the source host.

      Another case is when a datagram must be fragmented to be forwarded
      by a gateway yet the Don't Fragment flag is on.  In this case the
      gateway must discard the datagram and may return a destination
      unreachable message.

      Codes 0, 1, 4, and 5 may be received from a gateway.  Codes 2 and
      3 may be received from a host.


